package com.ash.c.behavioral.mediator;

/**
 * 定义:用一个中介者对象封装一系列的对象交互，中介者使各对象不需要显示的互相作用
 *
 * @author Ash
 */
public class Main {

    public static void main(String[] args) {
        // 创建一个中介者
        AMediator mediator = new Mediator();

        // 创建两个同事
        ColleagueA colleagueA = new ColleagueA(mediator);
        ColleagueB colleagueB = new ColleagueB(mediator);

        // 中介者分别与每个同事建立联系
        mediator.addColleague("ColleagueA", colleagueA);
        mediator.addColleague("ColleagueB", colleagueB);

        // 同事们开始工作
        colleagueA.self();
        colleagueA.out();
        System.out.println("======================合作愉快，任务完成！\n");

        colleagueB.self();
        colleagueB.out();
        System.out.println("======================合作愉快，任务完成！");

    }
}
